<?php

namespace ManiaLivePlugins\MLEPP\ManiaRecords\Runnables;

Class Request extends \ManiaLive\Threading\Runnable {

    private $data;
    public $url;
    public $serverLogin;

    function setRequest($data) {
        $this->data = $data;
    }

    function run() {
        $sendPost = urlencode(base64_encode(serialize($this->data)));
        try {
            $curl = curl_init($this->url . "/api_v_4_0_0.php");
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($curl, CURLOPT_POST, true);
            curl_setopt($curl, CURLOPT_POSTFIELDS, array("data" => $sendPost));
            curl_setopt($curl, CURLOPT_REFERER, $this->serverLogin);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
            $body = curl_exec($curl);
            curl_close($curl);
            
            $ret = unserialize($body);
            return $ret;
        } catch (\Exception $e) {
            return NULL;
        }
    }

}

?>